﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using GreenyMeter.DOM.DataBaseAcces;

namespace GreenyMeter.DOM.Objets
{
    public class Food
    {
        #region Atributes


        private int _foodId;
        public int FoodId
        {
            get { return _foodId; }
            set { _foodId = value; }
        }

        private int _foodSourceId;
        public int FoodSourceId
        {
            get { return _foodSourceId; }
            set { _foodSourceId = value; }
        }

        private int _foodTypeId;
        public int FoodTypeId
        {
            get { return _foodTypeId; }
            set { _foodTypeId = value; }
        }

        private string _foodName;
        public string FoodName
        {
            get { return _foodName; }
            set { _foodName = value; }
        }

        private string _description;
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        private string _foodImgUrl;
        public string FoodImgUrl
        {
            get { return _foodImgUrl; }
            set { _foodImgUrl = value; }
        }



        private Food(DataRow row)
        {
            if (!row.IsNull("FoodId"))
            {
                _foodId = int.Parse(row["FoodId"].ToString());
            }

            if (!row.IsNull("FoodSourceId"))
            {
                _foodSourceId = int.Parse(row["FoodSourceId"].ToString());
            }

            if (!row.IsNull("FoodName"))
            {
                _foodName = row["FoodName"].ToString();
            }

            if (!row.IsNull("Description"))
            {
                _description = row["Description"].ToString();
            }

            if (!row.IsNull("FoodImgUrl"))
            {
                _foodImgUrl = row["FoodImgUrl"].ToString();
            }


        }


        #endregion

        public static DataTable getAllFoodTypes()
        {

            SqlDataAcces sqlQuery = new SqlDataAcces();
            List<SqlDaAccesParameters> param = new List<SqlDaAccesParameters>();
            return sqlQuery.GetDataTable("usp_GetAllFoodTypes", param);
        }
        public static DataTable getAllFoodCategories()
        {

            SqlDataAcces sqlQuery = new SqlDataAcces();
            List<SqlDaAccesParameters> param = new List<SqlDaAccesParameters>();
            return sqlQuery.GetDataTable("usp_GetAllFoodCategories", param);
        }

       
        
        public static DataTable getFoodType(int userID)
        {

            SqlDataAcces sqlQuery = new SqlDataAcces();
            List<SqlDaAccesParameters> param = new List<SqlDaAccesParameters>();
            param.Add(new SqlDaAccesParameters("@UserID", userID));
            return sqlQuery.GetDataTable("usp_ExperiencesSelectByUser", param);
        }

        public static DataTable getFoodTypesByCategoryId(Int32 CategoryId)
        {

            SqlDataAcces sqlQuery = new SqlDataAcces();
            List<SqlDaAccesParameters> param = new List<SqlDaAccesParameters>();
            param.Add(new SqlDaAccesParameters("@FoodCategoryId", CategoryId));
            return sqlQuery.GetDataTable("usp_GetFoodTypesByCategoryId", param);
            
        }

        public static DataTable usp_getIngredientTypesByFoodTypeId(Int32 FoodTypeId)
        {

            SqlDataAcces sqlQuery = new SqlDataAcces();
            List<SqlDaAccesParameters> param = new List<SqlDaAccesParameters>();
            param.Add(new SqlDaAccesParameters("@FoodTypeId", FoodTypeId));
            return sqlQuery.GetDataTable("usp_GetIngredientTypesByFoodTypeId", param);
            
        }
        public static DataTable getFoodIngredientsByIngredientTypeId(Int32 CategoryId)
        {

            SqlDataAcces sqlQuery = new SqlDataAcces();
            List<SqlDaAccesParameters> param = new List<SqlDaAccesParameters>();
            param.Add(new SqlDaAccesParameters("@IngredientTypeId", CategoryId));
            return sqlQuery.GetDataTable("usp_GetFoodIngredientsByIngredientTypeId", param);
            
        }
        
    }
}